package com.example.demo.controller;

import com.example.demo.entity.Visitor;
import com.example.demo.service.VisitorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin(origins = "http://localhost:8080")
@RequestMapping("/visitor")
public class VisitorController {

    @Autowired
    private VisitorService visitorService;

    @GetMapping("/list")
    public List<Visitor> list() {
        return visitorService.getVisitorList();
    }
    @GetMapping("/getVisitorById")
    public Visitor getVisitorById(int id) {
        return visitorService.getVisitorById(id);
    }
    @PostMapping("/add")
    public void addVisitor( @RequestBody Visitor visitor) {
        visitorService.addVisitor(visitor);

    }
}
